package com.ntt.benew.dictionary.view

import android.content.Context
import android.graphics.Typeface
import android.text.TextUtils
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.SizeUtils
import com.ntt.benew.dictionary.R
import com.ntt.benew.dictionary.utils.setGradientDrawableOnlyStroke

/**
 * Created by Android Studio.
 * User: tw
 * Date: 2023/11/3
 * Time: 09:56
 * 带边框的文本组件
 */
class BorderedTextView(context: Context,attrs: AttributeSet? = null) : AppCompatTextView(context,attrs) {

    var mBorderedColor: Int = R.color.ntt_FFB604
    var mBgColor: Int = R.color.ntt_FFF8E6

    init {
        val dp10 = SizeUtils.dp2px(10f)
        val dp5 = SizeUtils.dp2px(5f)
        setPadding(dp10, dp5, dp10, dp5)
        setGradientDrawableOnlyStroke(
            dp5,
            ContextCompat.getColor(context, mBorderedColor),
            1,
            ContextCompat.getColor(context, mBgColor)
        )
        ellipsize = TextUtils.TruncateAt.END
        setTextColor(ContextCompat.getColor(context, R.color.ntt_26323F))
        textSize = 18f
        typeface = Typeface.defaultFromStyle(Typeface.BOLD)
    }

    fun setBorderedColor() {

    }
}